var choess=1;

function switchto(a) {
    if (a==1)
    {
        choess=1;
        removechoess();
        $("#student").addClass("chooes");
        $('html').find('input').eq(0).attr("placeholder","学号");
    }else if (a==2){
        removechoess();
        choess=2;
        $("#teacher").addClass("chooes");
        $('html').find('input').eq(0).attr("placeholder","教师账号");
    }else if (a==3){
        removechoess();
        choess=3;
        $("#admin").addClass("chooes");
        $('html').find('input').eq(0).attr("placeholder","管理员账号");
    }
}
function removechoess() {
    $("#student").removeClass("chooes");
    $("#teacher").removeClass("chooes");
    $("#admin").removeClass("chooes");

}
$(function(){
    $(".btn").click(function(){
        var username = $("#inputUsername").val();//取值
        var password = $("#password").val();
        if(!username){
            alert("用户名必填!");
            $("#inputUsername").focus();//获取焦点
            return ;
        }
        if(!password){
            alert("密码必填!");
            $("#password").focus();//获取焦点
            return ;
        }
        var url
        var home
        if (choess==1){
            url="/student/login/doLogin";
            home="/student/home";
        }else if (choess==2){
            url="/teacher/login/doLogin";
            home="/teacher/home";
        }else if (choess==3){
            url="/admin/login/doLogin";
            home="/admin/home";
        }
        //var param = "username="+username+"&password="+password;
        var param = {"username":username,"password":password};
        $.post(url,param,function(result){
            if(result.success){
                alert("登录成功!");
                window.location.href=home;
                //document.write("<h1>Out with the old - in with the new!</h1>");
            }else{
                alert("账号或者密码错误!");
            }
        });
    });

});